import java.util.ArrayList;
import java.util.Arrays;


public class MaxSumSequence {

	
	
	public static void main(String[] args) {
		
		int[] arr = {1,1,-5,4,1,-1,5,2,-2,-2,-6};
		ArrayList<Integer> tempArr1 = new ArrayList<Integer>();
		ArrayList<Integer> longestSeqArr = new ArrayList<Integer>();
		
		
		for (int i = 0; i < arr.length; i++) {
				tempArr1.clear();
			for (int j = i; j < arr.length; j++) {
				tempArr1.add(arr[j]);
				
			if(arr[j] > SumOfArr(longestSeqArr)){
				longestSeqArr.clear();
				longestSeqArr.add(arr[j]);	
				continue;
			}
			
			if (SumOfArr(tempArr1)>SumOfArr(longestSeqArr)) {
				longestSeqArr.clear();
				for (int j2 = 0; j2 < tempArr1.size(); j2++) {
					longestSeqArr.add(tempArr1.get(j2));
				}
			}
			
			
			}
		}
		for (Integer integer : longestSeqArr) {
			System.out.print(integer+" ");
		}
	}
	public static int SumOfArr(ArrayList<Integer> arr){
		int sum = 0;
		for (int i = 0; i < arr.size(); i++) {
			sum+=arr.get(i);
		}
		return sum;
	}

}
